<!DOCTYPE html>
<html lang="en">
	<head>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta http-equiv="Access-Control-Allow-Origin" content="*">
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="__STATIC__/home/css/reset.css">
		<script src="__STATIC__/home/js/base.js"></script>
		<link rel="stylesheet" href="__STATIC__/home/css/login.css">
	</head>
<body>
	<div class="sr">
		<div class="zh">
			<span>账号</span>
			<input id="username" type="text" placeholder="请输入账号">
		</div>
		<div class="mm">
			<span>密码</span>
			<input id="password" type="password" placeholder="请输入密码">
		</div>
		<!-- 弹窗 -->
		<p class="tc"></p>
	</div>
	<button class="login" id="login">登录</button>
	<div class="san">
		<img src="__STATIC__/home/images/disanfang.png" alt="">
		<a href="javscript:;">
			<img src="__STATIC__/home/images/weixin.png" alt="">
		</a>
	</div>
	
</body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
	/*弹窗控制*/
	function toggle(str,time) {
		$('.tc').show().html(str);
		setTimeout(function() {
			$('.tc').hide()
		},time)
	}
	/*登录接口*/
	$('#login').click(function() {
		var username = $('#username').val(),
			password = $('#password').val();
		if(username && password) {
			$.ajax({
				url: "{:url('login/login')}",
				type: 'post',
				data: {
					name:username,
					pass:password
				},
				success:function(data) {
					console.log(data)
                    var status = JSON.parse(data);
					if(status.msg == 1) {
						toggle(status.info,1000);
						// document.cookie="token="+status.token;
						window.location.href= "{:url('home/index/index')}";
					}else if(status.msg == 2) {
						toggle(status.info,10000)
					}else {
						toggle(status.info,1000)
					}	
				}
			})
		}else {
			toggle('账号密码不能为空',1000)
		}
	})
	
</script>
</html>